#include<iostream>
#include<cstdlib>
#include"BiTree.h"
using namespace std;

ElemType Leaf_Sum(BTNode* root)
{
	if (!root->lchild && !root->rchild)
		return root->data;

	return Leaf_Sum(root->lchild) + Leaf_Sum(root->rchild);
}

int main()
{
	/*
		1
	5       2
		 3     4
	*/
	BTNode* BTree;
	ElemType a[] = { 1,5,2,3,4 };
	ElemType b[] = { 5,1,3,2,4 };

	BTree = CreateBTree(a, b, 5);

	int sum = Leaf_Sum(BTree);

	cout << sum << endl;

	return 0;
}